<?php
namespace Home\Controller;
use Think\Controller;

class IndexController extends Controller {
    public function index(){
        $this->is_auth = session('mobile');
        $this->display();
    }

    public function chkcode(){
        header("Content-Type: text/html; charset=UTF-8");
        $config =    array(
            'fontSize'    =>    30,    // 验证码字体大小
            'length'      =>    4,     // 验证码位数
            'useNoise'    =>    false, // 关闭验证码杂点
        );
        ob_clean();
        $Verify = new \Think\Verify($config);
        $Verify->entry();
    }

    /**
     * 验证码验证
     * @access
     * @param $code
     * @param string $id
     * @return bool
     * @author:ss.wu
     */
    public function check_verify($code, $id = ''){
        $verify = new \Think\Verify();
        return $verify->check($code, $id);
    }

    public function login(){
        $this->display();
    }

    public function checklogin(){
        if($_POST){
            $code = I('post.verify');
        if(!$this->check_verify($code)){
            $this->error('验证码输入错误');
        }else{
  
              $use=M('userinfo');
              $rs = $use -> where('tel='.$_POST['users'])->find();
              // dump($rs);exit;
             if($rs){
                 $_SESSION['userid'] = $rs['id'];
              $this->success('登录成功!',U('Index/index'));
             }else{
                 $this->error('账号或密码错误');
             }

          
        }

          
          
        }
    }
}